import { request } from "../untils/request.js";
export default {
    get: ({ curPage, eachPage }) => request({
        type: "GET",
        url: "/api/admins",
        data: { curPage, eachPage },
    }),

    getOne: _id => request({
        type: "GET",
        url: `/api/admins/${_id}`,
    }),

    add: admin => request({
        type: "POST",
        url: "/api/admins/add",
        data: admin,
    }),

    // 删除数据
    remove:async removeData=>{
        return await request({
            type:"POST",
            url:"/api/admins/remove",
            data:removeData,
        })
    },
    // 修改
    change: async (newData) => {
        return await request({
            type: "PUT",
            url: "/api/admins/change",
            data: newData,
        })
    },
   // 通过_id查找整条数据
    findOne: async _id =>
    await request({
        type: "GET",
        url: `/api/admins/findOne/${_id}`,
    }),


    // 获取所有电影数据  排片用的
    getall: () =>
        request({
            type: "GET",
            url: "/api/admins/adminsListAll",
        }),
        adminsLogin: async ({ adminsname, adminspassword }) =>
        await request({
          type: "POST",
          data: { adminsname, adminspassword },
          url: "/api/admins/adminsLogin",
        }),
      adminsReg: async ({ adminsname, adminspassword }) =>
        await request({
          type: "POST",
          data: { adminsname, adminspassword },
          url: "/api/admins/adminsReg",
        }),
      setToken: token => (localStorage["_t"] = token),
      getToken: () => {
        localStorage["_t"]
      }
    };



